import request from '@/utils/request'
import Qs from 'qs'

export function spuTree() {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.log',
      _mt: 'getSpuBigTree'
    }
  })
}

export function listGoods(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.log',
      _mt: 'list',
      ...query
    }
  })
}

export function editGoods(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.log',
      _mt: 'edit',
      spuDTO: JSON.stringify(data)
    })
  })
}

export function deleteGoods(id) {
  return request({
    method: 'post',
    params: {
      _gp: 'admin.log',
      _mt: 'delete',
      spuId: id
    }
  })
}

export function batchDeleteGoods(ids) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.log',
      _mt: 'batchDelete',
      ids: JSON.stringify(ids)
    })
  })
}

export function createGoods(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.log',
      _mt: 'create',
      spuDTO: JSON.stringify(data)
    })
  })
}

export function detailGoods(id) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.log',
      _mt: 'detail',
      spuId: id
    }
  })
}

export function freezeOrActivtion(id, status) {
  return request({
    method: 'post',
    params: {
      _gp: 'admin.log',
      _mt: 'freezeOrActivation',
      spuId: id,
      status: status
    }
  })
}

export function searchGoods(title) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.log',
      _mt: 'searchSpu',
      title
    }
  })
}

export function statistics(status, ids, datePram) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.log',
      _mt: 'statistics',
      status: JSON.stringify(status),
      ids: JSON.stringify(ids),
      ...datePram
    })
  })
}

export function detailLogGoods(shopId, type, gmtDay) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.log',
      _mt: 'logDetail',
      shopId: shopId,
      type: type,
      gmtDay: gmtDay
    }
  })
}
